<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
    <h:head>
        <title>Tra cứu thông tin dịch vụ</title>
    </h:head>
    <h:body> 
        <link type="text/css" rel="stylesheet" href="../css/main.css" />        
        <style type="text/css">
            .ui-widget{font-size:95% !important;}
            .ui-layout-unit-content{background-color: #E5E5E5;border-width: 0px}      
            .ui-widget{border-width: 0px;color: red}
        </style>
        <div align="center" id="bodyForm" >            
            <div style="width: 100%;">
                <p:layoutUnit id="top" position="north" size="auto">
                    <ui:insert name="menu">
                        <ui:include src="../../templates/menu.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit id="center" position="center" size="400">
                    <h:form id="form">
                        <p:dialog modal="true" widgetVar="statusDialog" header="#{bundle_items_vi.Searching}"   
                                  draggable="false" closable="false">  
                            <p:graphicImage value="../../images/ajax-loader.gif" />  
                        </p:dialog>
                        <p:growl id="msg"/>
                        <br/>
                        <h:outputText value="Số điện thoại: "/><p:inputText value="#{serviceInforController.phoneNumberS}"/> 
                        <p:commandButton value="Tìm" action="#{serviceInforController.search()}" update=":form" onclick="statusDialog.show()" oncomplete="statusDialog.hide()"/>
                        <p:dataTable value="#{serviceInforController.lazyDataModel}" lazy="true" var="v" paginator="true" rows="20" paginatorPosition="bottom">                            

                            <p:column  sortBy="phoneNumber" headerText="Số điện thoại">
                                <h:outputText value="#{v.phoneNumber}" style="float: right"/>
                            </p:column>

                            <p:column sortBy="productName" headerText="Tên sản phẩm">
                                <h:outputText value="#{v.productName}" style="float: right"/>
                            </p:column>

                            <p:column sortBy="createTime" headerText="Thời gian đăng kí">
                                <h:outputText value="#{v.createTime}" style="float: right"/>
                            </p:column>

                            <p:column sortBy="cancelTime" headerText="Thời gian hủy">
                                <h:outputText value="#{v.cancelTime}" style="float: right"/>
                            </p:column>

                            <p:column sortBy="status" headerText="Trạng thái">
                                <h:outputText value="#{v.status eq 1 ? 'Hoạt động':'Ngừng hoạt động'}" style="float: right"/>
                            </p:column>

                            <p:column sortBy="partnerName" headerText="Đối tác">
                                <h:outputText value="#{v.partnerName}" style="float: right"/>
                            </p:column>     

                            <p:column headerText="Xem tin nhắn" style="width: 1%">
                                <div align="center">
                                    <p:commandButton styleClass="ui-icon ui-icon-mail-closed" style="width: 20px;height: 20px;" action="#{serviceInforController.viewMsg(v)}" update=":formViewMsg" onclick="dlgViewMsg.show()"/>
                                </div>
                            </p:column>
                            <p:column headerText="Thông tin cước" style="width: 1%">
                                <div align="center">
                                    <p:commandButton styleClass="ui-icon ui-icon-search" style="width: 20px;height: 20px;" action="#{serviceInforController.viewBilling(v)}" update=":formViewBilling" onclick="dlgViewBilling.show()"/>
                                </div>
                            </p:column>

                        </p:dataTable>
                    </h:form>
                    <!--dialog view Msg-->
                    <p:dialog modal="true" widgetVar="dlgViewMsg" header="Tin nhắn" resizable="false">
                        <p:scrollPanel style="width: 1000px;height: 600px" mode="native">
                            <h:form style="width: 100%;height: 100%;" id="formViewMsg">
                                <p:growl id="msgView"/>
                                <p:dataTable value="#{serviceInforController.listSMSBatches}" var="v" paginator="true" rows="20" paginatorPosition="bottom">

                                    <p:column headerText="Tên sản phẩm">
                                        <h:outputText value="#{v.productName}" style="float: right"/>
                                    </p:column>

                                    <p:column headerText="Người gửi">
                                        <h:outputText value="#{v.sender}" style="float: right"/>
                                    </p:column>

                                    <p:column headerText="Tin nhắn">
                                        <h:outputText value="#{v.message}" style="float: right"/>
                                    </p:column>

                                    <p:column headerText="Thời gian xử lí">
                                        <h:outputText value="#{v.executedTime}" style="float: right"/>
                                    </p:column>                                    

                                    <p:column headerText="Trạng thái gửi">
                                        <h:outputText rendered="#{v.deliveryStatus eq '0'}" value="Không có thông tin" style="float: right"/>
                                        <h:outputText rendered="#{v.deliveryStatus eq 'DeliveredToTerminal'}" value="Thành công" style="float: right"/>
                                        <h:outputText rendered="#{v.deliveryStatus eq 'DeliveredToNetwork'}" value="Thành công" style="float: right"/>
                                        <h:outputText rendered="#{v.deliveryStatus eq 'DeliveryImpossible'}" value="Thất bại" style="float: right"/>
                                    </p:column>

                                    <p:column headerText="Loại tin nhắn">
                                        <h:outputText value="#{v.contentType}" style="float: right"/>
                                    </p:column>                                                        

                                    <p:column headerText="Url">
                                        <h:outputText value="#{v.url}" style="float: right"/>
                                    </p:column>                                                        
                                </p:dataTable>
                            </h:form>
                        </p:scrollPanel>
                    </p:dialog>
                    <!--dialog viewBilling-->
                    <p:dialog modal="true" widgetVar="dlgViewBilling" header="Thông tin cước" resizable="false">
                        <h:form style="width: 100%;height: 100%;" id="formViewBilling">
                            <p:growl id="billingView"/>
                            <p:dataTable value="#{serviceInforController.listBilling}" var="b" paginator="true" rows="20" paginatorPosition="bottom">
                                <p:column headerText="Thời gian">
                                    <h:outputText value="#{b.timeStamp}" style="float: right"/>
                                </p:column>
                                <p:column headerText="Sản phẩm">
                                    <h:outputText value="#{b.product_name}" style="float: right"/>
                                </p:column>
                                <p:column headerText="Giá cước">
                                    <h:outputText value="#{b.cost}" style="float: right"/>
                                </p:column>
                            </p:dataTable>
                        </h:form>
                    </p:dialog>
                </p:layoutUnit>
                <p:layoutUnit id="bottom" position="bottom" size="60">
                    <ui:insert name="footer">
                        <ui:include src="../../templates/footer.xhtml"/>
                    </ui:insert>
                </p:layoutUnit>
            </div>
        </div>
    </h:body>
</html>

